import request from '@/utils/request'
import qs from 'qs'

// 查询物品分类信息列表
export function listCategory(query) {
  return request({
    url: '/team/category/list',
    method: 'get',
    params: query
  })
}

// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: '/team/category/treeselect',
    method: 'get'
  })
}

// 查询物品分类信息详细
export function getCategory(id) {
  return request({
    url: '/team/category/' + id,
    method: 'get'
  })
}

// 新增物品分类信息
export function addCategory(data) {
  return request({
    url: '/team/category',
    method: 'post',
    data: data
  })
}

// 修改物品分类信息
export function updateCategory(data) {
  return request({
    url: '/team/category',
    method: 'put',
    data: data
  })
}

// 删除物品分类信息
export function delCategory(id) {
  return request({
    url: '/team/category/' + id,
    method: 'delete'
  })
}

// 迁移物品
export function migrate(sourceId, targetId, subtype) {
  let params = { sourceId, targetId, subtype }
  let formParams = qs.stringify(params, { indices: false });

  return request({
    url: '/team/category/migrate',
    data: formParams,
    headers: { 'content-type': 'application/x-www-form-urlencoded' }, // 表单参数
    method: 'post'
  })
}
